﻿@page "/JsonEditTest"

@inject IJSRuntime JS;

<h3>JsonEditTest</h3>

<button @onclick="OpenJsonDialog" class="btn btn-primary mt-2">JSON 文件编辑器</button>

@code {
    protected override async Task OnInitializedAsync()
    {

    }

    [CascadingParameter] private Radzen.Dialog _dialog { get; set; }
    [Inject] private Radzen.DialogService _dialogService { get; set; }

    private async Task OpenJsonDialog()
    {
        var result = await _dialogService.OpenAsync<CustomJsonEditorDialog>("JSON编辑器",
            new Dictionary<string, object>() { { "InitialContent", "{\"BasicInfo\":{\"RecipeId\":\"c710540d-6926-4279-b0fc-9279606b0d2e\",\"RecipeName\":\"trench-0624-01-Published\",\"WaferId\":\"d6b7fa17-521e-4c7c-8559-466912dc106e\",\"WaferType\":1,\"MeasurementId\":null,\"MeasurementUseCaseType\":4,\"WaferCenterX\":0.1691779,\"WaferCenterY\":0.1526852,\"WaferRadius\":0.15,\"WaferDiameter\":0.3,\"WaferPredeterminedAngle\":0.0,\"ManualCalibrationAngle\":0.0,\"AngleValueX\":0.0,\"AngleValueY\":0.0,\"ManualCalibrationAngleValueX\":0.0236236,\"ManualCalibrationAngleValueY\":1.5516138,\"SingleShotWidth\":0.025,\"SingleShotHeight\":0.031,\"SingleDieWidth\":0.0,\"SingleDieHeight\":0.0,\"ZeroShotOffsetX\":0.001,\"ZeroShotOffsetY\":0.02,\"NonPatternedDistance\":0.0,\"IsNeedLinearPosition\":false,\"IsReferenceScanNeed\":false,\"MarkConfidence\":70.0,\"FlattenAlgorithmTypeWithNid\":1,\"FlattenAlgorithmTypeWithImage\":0,\"IsWaferCenteringNeed\":false,\"IsWaferCenteringWithNotchNeed\":false,\"MeasureStructureGreyValueMin\":0,\"MeasureStructureGreyValueMax\":0,\"MeasureStructureHeightValueMin\":0.0,\"MeasureStructureHeightValueMax\":0.0,\"MeasureStructureValueAnalysisType\":0,\"KernelSize\":0,\"RecipeFullPath\":null,\"IsXRayEnabled\":false,\"XRayDuration\":5.0,\"MarkOffsetDistance\":0.0005,\"StaticPrecisionJobMode\":0,\"StaticCycleCount\":1,\"LLCInfo\":{\"WaferLLCX\":0.001,\"WaferLLCY\":0.02,\"WaferCalibrationLLCX\":0.000914257,\"WaferCalibrationLLCY\":0.019890809}},\"MarkInfoConfigs\":[{\"ShotIndexX\":0,\"ShotIndexY\":0,\"MarkInfoDetails\":[{\"MarkTemplateName\":\"cbace984-5d36-4b73-b387-f99387c8e30c\",\"MarkOffsetX\":0.0,\"MarkOffsetY\":0.0}]}],\"MeasurementInfoConfigs\":[{\"ShotIndexX\":0,\"ShotIndexY\":0,\"ToiDetails\":[{\"DieIndexX\":0,\"DieIndexY\":0,\"ToiId\":\"401816d6-f3b5-4e51-8cf5-177fda1dfb6e\",\"ToiName\":\"MP1\",\"ToiOffsetX\":0.00228,\"ToiOffsetY\":0.007706,\"StartLocationX\":0.0,\"StartLocationY\":0.0,\"EndLocationX\":0.0,\"EndLocationY\":0.0,\"MeasurementCount\":1,\"Direction\":0,\"MethodId\":\"281c21ce-9678-416e-9d87-126a27b2411f\"}]}],\"AfmParameterInfos\":[{\"AfmParameterType\":0,\"AfmMeasureParameter\":{\"ImageWidth\":2.4E-05,\"ImageHeight\":2.4E-05,\"RotationAngle\":0.0,\"ScanTime\":20.0,\"Line\":512,\"Point\":512,\"SetPoint\":85.0,\"Pgain\":19000.0,\"Igain\":1800.0,\"VibratingAmpl\":0.6,\"OperateModeType\":3}},{\"AfmParameterType\":1,\"AfmMeasureParameter\":{\"ImageWidth\":2.4E-05,\"ImageHeight\":2.4E-05,\"RotationAngle\":0.0,\"ScanTime\":20.0,\"Line\":512,\"Point\":512,\"SetPoint\":85.0,\"Pgain\":19000.0,\"Igain\":1800.0,\"VibratingAmpl\":0.6,\"OperateModeType\":3}}],\"ProfileScanInfo\":null,\"VibratingFreqConfig\":{\"Enabled\":false,\"VibratingAmpl\":0.5},\"Shots\":[{\"ShotIndexX\":0,\"ShotIndexY\":0}],\"ToiDetails\":[{\"DieIndexX\":0,\"DieIndexY\":0,\"ToiId\":\"401816d6-f3b5-4e51-8cf5-177fda1dfb6e\",\"ToiName\":\"MP1\",\"ToiOffsetX\":0.00228,\"ToiOffsetY\":0.007706,\"StartLocationX\":0.0,\"StartLocationY\":0.0,\"EndLocationX\":0.0,\"EndLocationY\":0.0,\"MeasurementCount\":1,\"Direction\":0,\"MethodId\":\"281c21ce-9678-416e-9d87-126a27b2411f\"}],\"AlignmentShots\":[{\"ShotIndexX\":0,\"ShotIndexY\":0},{\"ShotIndexX\":1,\"ShotIndexY\":0},{\"ShotIndexX\":0,\"ShotIndexY\":1}]}" } },
            new DialogOptions() { Width = "1000", Height = "1000" });
        if (result != null)
        {
            
        }
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await Task.Delay(300); 
        }
    }
}
